﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;
using BLL;
namespace UI.ModMini
{
    public partial class HostelList : System.Web.UI.Page
    {
        MiniBiz miniBiz = new MiniBiz();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             
                btnAdd.Attributes.Add("onclick", "javascript:ShowLink('HostelAdd.aspx',800,550);");
               
                    BondData("", "", "", "Y");
             
            }
        }
        private void BondData(string serWord, string bTime, string eTime, string statu)
        {
            DataTable dt =miniBiz.GetHostelLists(serWord, bTime, eTime, statu);

            if (dt.Rows.Count > 0)
            {
                lbAmount.Text = "合计:    " + dt.Rows.Count;
            }
            else
            {
                lbAmount.Text = "";
            }
            gvList.DataSource = dt;
            gvList.DataBind();
        
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string serWord = txtSerWord.Text.Trim();
            string statu = ddlStatu.SelectedValue;
            BondData(serWord, "", "", statu);
        }

        protected void btnExcel_Click(object sender, EventArgs e)
        {
            string serWord = txtSerWord.Text.Trim();
            string statu = ddlStatu.SelectedValue;
            ExcelUtility.ExportDsToXls(this, miniBiz.GetHostelLists(serWord, "", "", statu), "HostelList.xls");
        }
        protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F3F8F8'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            }
        }
     
    }
}